<template>
    <template v-if="!mode || mode == 0">
        <el-table :data="gamelist" :style="style" empty-text="没有游戏了" 
        @row-click="OnRowClick">
            <el-table-column prop="date" label="日期" width="180" />
            <el-table-column prop="title" label="游戏名" />
        </el-table>
    </template>
    <template v-else-if="mode == 1">
        <el-table :data="gamelist" :style="style" empty-text="没有游戏了"
        @selection-change="OnSelectionChanged">
            <el-table-column fixed type="selection" width="55" />
            <el-table-column prop="date" label="日期" width="180" />
            <el-table-column prop="title" label="游戏名"/>
            <el-table-column fixed="right" label="操作" min-width="120px">
                <template v-slot="scope">
                    <el-button link type="primary" size="small" 
                    @click="OnEdit(scope.$index,scope.row)">
                        编辑
                    </el-button>
                    <el-button link type="danger" size="small"
                    @click="OnDelete(scope.$index,scope.row)">
                        删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
    </template>
</template>
<script setup>
/**
 * gamelist:[
 *  {id:number,name:string,date:string,url:string},...
 * ]
 * 
 * mode:enum{
 * 0|null --用户
 * 1      --管理员
 * }
 */
defineProps(['style','gamelist','OnRowClick','mode','OnEdit','OnDelete','OnSelectionChanged']);
</script>